home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: Incompatible function pointers?
- Date: Thu, 18 Apr 1996 09:22:27 +0200
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <3175EDB3.2781E494@intellektik.informatik.th-darmstadt.de>
- References: <4l3fp5INN1ak@sit.sps.mot.com>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (X11; I; SunOS 4.1.3 sun4m)
-
- Matthew Moss wrote:
- >
- > Can anyone tell me why this won't work? All compilers I've tried complain
- > about passing G::Create() into test().... I would've thought this a problem
- > if they were member functions, but G::Create() is static.
- >
- > I couldn't easily find anything about this in the ARM or ANSI references...
- > Thanks...
- >
- > class A {
- > [ ... ]
- > public:
- > static G* Create(A*);
- > };
- >
- > typedef void* (*CreatorFP)(A*);
-
- This should be 'typedef G* (*CreatorFP)(A*)'.
-
- >
- > [ ... ]
- >
- > void* test(A *a, CreatorFP cfp)
- > {
- > return (*cfp)(a);
- > }
- >
- > void main()
- > {
- > A *a = new A(65);
- > G *g = (G*) test(a, G::Create);
- >
- > delete g;
- > delete a;
- > }
-
- Enno
-